package com.flyduck.system.vo.menu.trans;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.flyduck.system.entity.SysMenuEntity;
import com.flyduck.system.vo.menu.SysMenuAddReqVO;
import com.google.common.base.Function;


/**
 * @program: flyduck-platform
 * @description:
 * @author: flyduck
 * @create: 2021-02-01 12:42
 **/
public class SysMenuAddReqVOToSysMenuEntity implements Function<SysMenuAddReqVO, SysMenuEntity> {

    @Override
    public SysMenuEntity apply(SysMenuAddReqVO reqVO) {
        SysMenuEntity sysMenuEntity = new SysMenuEntity();
        BeanUtil.copyProperties(reqVO,sysMenuEntity);
        if (ObjectUtil.isNotNull(reqVO.getParentId())) {
            sysMenuEntity.setParentId(Long.valueOf(reqVO.getParentId()));
        }
        sysMenuEntity.setSort(Integer.valueOf(reqVO.getSort()));
        return sysMenuEntity;
    }
}
